fix(lint): stop font_family_without_font_face flagging system-ui stacks and var()#1796
Draft
miguel-heygen wants to merge 1 commit into
Draft
fix(lint): stop font_family_without_font_face flagging system-ui stacks and var()#1796miguel-heygen wants to merge 1 commit into
miguel-heygen wants to merge 1 commit into
Conversation
…ks and var() The font_family_without_font_face rule raised a blocking error on two legitimate, very common cases: 1. The `-apple-system, BlinkMacSystemFont` system-ui stack. These two tokens are the cross-browser incantation for the platform UI font (synonyms of `system-ui`); they name no font file, so demanding an @font-face for them is wrong. They appear in almost every CSS reset. 2. `font-family: var(--x)` indirection. The shared family extractor took the literal `var(--heading)` as a font name. The linter cannot statically resolve a custom property, so it must not flag it. Fix at the root: add the two system-ui synonyms to GENERIC_FAMILIES, and skip any parenthesised (function) token in the shared family extractor so both this rule and system_font_will_alias stop misreading var(). A real undeclared font sitting in the same stack is still flagged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
font_family_without_font_facelint rule raises a blocking error on two legitimate, extremely common patterns, forcing authors to mutilate ordinary CSS to get a clean lint:The
-apple-system, BlinkMacSystemFont, ...system-ui stack. Those two tokens are the standard cross-browser incantation for the platform UI font (synonyms ofsystem-ui). They name no font file, so demanding an@font-facefor them is wrong. The stack appears in nearly every CSS reset, so any default-styled composition trips the rule.font-family: var(--x)indirection. The shared family extractor treated the literal stringvar(--heading)as a font name. The linter cannot statically resolve a custom property, so it must not flag it. (var(--x, 'Inter')fallbacks were also mis-parsed by the comma split.)Both surface as
errorseverity, which blocks the render gate.Fix (root cause)
-apple-systemandblinkmacsystemfonttoGENERIC_FAMILIES(they aresystem-uisynonyms).extractUsedFontFamilies, so bothfont_family_without_font_faceandsystem_font_will_aliasstop misreadingvar().A real undeclared font sitting in the same stack (e.g.
'Aeonik', -apple-system, sans-serif) is still flagged, exactly as before.Tests
Added cases to
fonts.test.tscovering the system-ui stack,var()indirection,var()with a quoted fallback, and the still-flagged mixed case. Reproduced the false positives first (both errored pre-fix), then confirmed the fix via the unit harness and the actualhyperframes lintCLI. Full lint package suite: 266 passing.